import { _decorator, CCFloat, Component, Node, tween } from 'cc';
const { ccclass, property } = _decorator;

@ccclass('ClickRotate')
export class ClickRotate extends Component {

    @property([CCFloat])
    angles: number[] = [];

    index = 0;
    delta = 1;
    isTween = false;

    Click() {
        if (this.isTween) return;
        this.isTween = true;
        if (this.index == 0) this.delta = 1;
        else if (this.index == this.angles.length - 1) this.delta = -1;
        this.index += this.delta;
        tween(this.node)
            .to(0.25, { angle: this.angles[this.index] })
            .call(() => { this.isTween = false; })
            .start();
    }
}


